package com.wonderland.sail.mybatis.parser.impl;

import com.wonderland.sail.mybatis.model.Page;
import com.wonderland.sail.mybatis.parser.SqlParser;

/**
 * Created by gaoxinyu on 2015-05-20.
 */
public class MysqlParser extends AbstractSqlParser implements SqlParser {

    @Override
    public String getPageSql(String sql, Page page) {
        return sql + getSortSql(page) + " limit " + page.getCurrentResult() + "," + page.getPageSize();
    }

    void getZhSortField(StringBuilder sortSql, String sortField) {
        sortSql.append("CONVERT(")
                .append(sortField.substring(0, sortField.lastIndexOf("IsZh")))
                .append(" USING gbk)");
    }
}
